<?php namespace Admin\Controller; 

use Hdphp\Controller\Controller;

class MessageController extends Controller{

	
    //动作
    public function index(){
    	$count = Db::table('message m')->join('fan f','f.openid','=','m.openid')->count();
		$page = Page::make($count);
		
		$data = Db::table('message m')->join('fan f','f.openid','=','m.openid')->limit(Page::limit())->orderBy('CreateTime','desc')->get();
		
		View::with('page',$page);
		View::with('data',$data);
       View::make();
    }
	
	
	public function reply()
	{

		$openid = Q('post.openid');
		$content = Q('post.Content');

		$re = Weixin::instance('customservice')->sendText($openid,$content);

		if($re)
		{
			View::ajax(array('code'=>0,'message'=>'发表成功'));
		}
		else{
			View::ajax(array('code'=>1,'message'=>'发送失败'));
		}
		
	}
}
